###########################################################################
### Christian Immigrants

ACDE.1 <- g.ACDE.fun(imp.data.1[imp.data.1$rel_muslim==0 & imp.data.1$rel_immigrant==1,])
ACDE.2 <- g.ACDE.fun(imp.data.2[imp.data.2$rel_muslim==0 & imp.data.2$rel_immigrant==1,])
ACDE.3 <- g.ACDE.fun(imp.data.3[imp.data.3$rel_muslim==0 & imp.data.3$rel_immigrant==1,])
ACDE.4 <- g.ACDE.fun(imp.data.4[imp.data.4$rel_muslim==0 & imp.data.4$rel_immigrant==1,])
ACDE.5 <- g.ACDE.fun(imp.data.5[imp.data.5$rel_muslim==0 & imp.data.5$rel_immigrant==1,])  

c.1 <- apply(ACDE.1, 2, mean)
c.2 <- apply(ACDE.2, 2, mean)
c.3 <- apply(ACDE.3, 2, mean)
c.4 <- apply(ACDE.4, 2, mean)
c.5 <- apply(ACDE.5, 2, mean)

s.1 <- apply(ACDE.1, 2, sd)
s.2 <- apply(ACDE.2, 2, sd)
s.3 <- apply(ACDE.3, 2, sd)
s.4 <- apply(ACDE.4, 2, sd)
s.5 <- apply(ACDE.5, 2, sd)

coefs <- cbind(c.1, c.2, c.3, c.4, c.5)
c.combined <- apply(coefs, 1, mean)

var.within <- cbind(s.1^2, s.2^2, s.3^2, s.4^2, s.5^2)
var.within <- apply(var.within, 1, mean)

m <- 5
var.between <- (coefs - c.combined)^2
var.between <-  apply(var.between, 1, sum)
var.between <-  (m-1)^-1 * var.between

s.combined <- sqrt(var.within + (1 + m^-1) * var.between )

combined.res <- cbind(c.combined, s.combined)
combined.res <- round(combined.res, 2)

rownames(combined.res) <- c("strongly oppose", "oppose", "neither", "support", "strongly support")